<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">

<h:panelGrid columns="5" cellpadding="2" id="pmCondicaoGridCondicao">

	<h:outputText value="Condicao *" />
	<h:outputText value="Codigo" />
	<h:outputText value="Forma de Pagamento *" />
	<h:outputText value="" />
	<h:outputText value="Tx. Juros (%)" />

	<p:inputText id="pmCondicaoDescricao"
		value="#{beanCondicao.condicao.descricao}" size="65" />
	<p:inputText id="pmCondicaoIdForma"
		value="#{beanCondicao.condicao.formaPagamento.id}" maxlength="40"
		size="5">
		<p:ajax event="change" listener="#{beanCondicao.hotFindForma}"
			update=":form:pmCondicaoGridCondicao" process="@this" />
	</p:inputText>
	<p:inputText id="pmCondicaoForma"
		value="#{beanCondicao.condicao.formaPagamento.descricao}" size="20"
		disabled="true" />
	<p:commandButton icon="ui-icon-search" id="pmCondicaoFindForma"
		title="Selecionar Forma de Pagamento" onclick="dConsultaForma.show()"
		type="button" />
	<p:inputText value="#{beanCondicao.condicao.taxaJuros}" size="9" />

</h:panelGrid>

<br></br>
<p:separator />

<h:panelGrid columns="4" id="pmCondicaoCamposParcela">
	<h:outputText value="Numero" />
	<h:outputText value="Dias" />
	<h:outputText value="Percentual (%)" />
	<h:outputText value="" />

	<p:inputText id="pmCondicaoNumero"
		value="#{beanCondicao.numeroParcelas}" disabled="true" />

	<p:inputText id="pmCondicaoDias" value="#{beanCondicao.parcela.dias}">
		<p:ajax event="change" />
	</p:inputText>

	<p:inputText id="pmCondicaoPercentual"
		value="#{beanCondicao.parcela.perc}">
		<p:ajax event="change" />
	</p:inputText>

	<p:commandButton id="pmCondicaoAddParcela" icon="ui-icon-plus"
		action="#{beanCondicao.addParcela}"
		update="pmCondicaoPanelParcelas, pmCondicaoCamposParcela"
		process="@this" />
</h:panelGrid>

<p:outputPanel id="pmCondicaoPanelParcelas">
	<br></br>
	<p:separator />

	<p:dataTable value="#{beanCondicao.parcelas}" var="parcela"
		emptyMessage="Não Há Parcelas">
		<p:column headerText="Parcela">
			<h:outputText value="#{parcela.numero}" />
		</p:column>
		<p:column headerText="Dias">
			<h:outputText value="#{parcela.dias}" />
		</p:column>
		<p:column headerText="Percentual">
			<h:outputText value="#{parcela.perc}" />
		</p:column>
		<p:column width="10">
			<p:commandButton icon="ui-icon-trash" title="Remover"
				action="#{beanCondicao.removeParcela}"
				update=":form:pmCondicaoPanelParcelas, :form:pmCondicaoCamposParcela">
				<f:setPropertyActionListener target="#{beanCondicao.parcela}"
					value="#{parcela}"></f:setPropertyActionListener>
			</p:commandButton>
		</p:column>
	</p:dataTable>
</p:outputPanel>
<br></br>
<p:separator />

<h:panelGrid columns="3" style="float: right;">
	<p:commandButton id="pmCondicaoSalvar" value="Salvar"
		action="#{beanCondicao.save}" oncomplete="dManterCondicao.hide()"
		update="form:condicaoPagamento" />
	<p:commandButton id="pmCondicaoLimpar" value="Limpar"
		action="#{beanCondicao.reinit}" update="form:condicaoPagamento" />
	<p:commandButton id="pmCondicaoVoltar" value="Voltar"
		onclick="dManterCondicao.hide()" />
</h:panelGrid>

<p:dialog header="Consultar Forma de Pagamento"
	widgetVar="dConsultaForma" id="pmCondicaoConsultaForma"
	resizable="false">
	<ui:include src="/formaPagamento/popConsultaFormaPagamento.xhtml"></ui:include>
</p:dialog>

</html>